﻿CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
PROJECT(LieRenBagSystemTests)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找必要的依赖
find_package(PkgConfig REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Threads REQUIRED)

# 包含目录
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/..
    ${CMAKE_CURRENT_SOURCE_DIR}/../NFLogicComm
    ${CMAKE_CURRENT_SOURCE_DIR}/../NFServerLogic
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFrame/NFComm
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFrame/NFComm/NFCore
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFrame/NFComm/NFShmStl
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFrame/NFComm/NFPluginModule
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFrame/NFComm/NFObjCommon
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/NFServer/NFServerComm
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/gtest
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/rapidjson
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/protobuf
)

# 设置源文件
set(TEST_SOURCES
    main.cpp
    BagSystemTestBase.cpp
    BagPageTest.cpp
    BagPageOpTest.cpp
    BagPageOpMgrTest.cpp
    ServicePackageTest.cpp
    ItemTest.cpp
    MockItemDesc.cpp
    EdgeCaseTest.cpp
    PerformanceTest.cpp
)

# 创建测试可执行文件
add_executable(LieRenBagTests ${TEST_SOURCES})

# 链接库
target_link_libraries(LieRenBagTests
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/lib64_debug/gtest.lib
    ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/lib64_debug/protobuf.lib
    Threads::Threads
)

if(UNIX)
    target_link_libraries(LieRenBagTests
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/lib64_debug/ubuntu/libgtest.a
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/lib64_debug/ubuntu/libprotobuf.a
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../thirdparty/lib64_debug/ubuntu/libgtest_main.a
        pthread
    )
endif()

# 设置编译选项
if(MSVC)
    target_compile_options(LieRenBagTests PRIVATE /W4)
else()
    target_compile_options(LieRenBagTests PRIVATE -Wall -Wextra -g)
endif()

# 设置测试属性
set_target_properties(LieRenBagTests PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
)

# 添加测试
enable_testing()
add_test(NAME BagSystemTests COMMAND LieRenBagTests) 